{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 Physical GPUs, 1 Logical GPUs\n"
     ]
    }
   ],
   "source": [
    "from data_read import *\n",
    "from net import *\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "import argparse\n",
    "\n",
    "import os\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "parser = argparse.ArgumentParser()\n",
    "\n",
    "\n",
    "parser.add_argument('--dataset_name', action=\"store\", dest= \"dataset_name\",default=\"GoogleMap\",help='MSCOCO')\n",
    "\n",
    "parser.add_argument('--batch_size', action=\"store\", dest=\"batch_size\", type=int, default=1,help='batch_size')\n",
    "\n",
    "parser.add_argument('--epoch_load_one', action=\"store\", dest=\"epoch_load_one\", type=int, default=20,help='load the epoch number from level one')\n",
    "\n",
    "parser.add_argument('--epoch_load_two', action=\"store\", dest=\"epoch_load_two\", type=int, default=20,help='load the epoch number from level two')\n",
    "\n",
    "parser.add_argument('--epoch_load_three', action=\"store\", dest=\"epoch_load_three\", type=int, default=20,help='load the epoch number from level three')\n",
    "\n",
    "parser.add_argument('--epoch_load_four', action=\"store\", dest=\"epoch_load_four\", type=int, default=20,help='load the epoch number from level three')\n",
    "\n",
    "\n",
    "\n",
    "parser.add_argument('-f')\n",
    "input_parameters = parser.parse_args()\n",
    "\n",
    "\n",
    "\n",
    "gpus = tf.config.experimental.list_physical_devices('GPU')\n",
    "if gpus:\n",
    "  # Restrict TensorFlow to only allocate 1GB of memory on the first GPU\n",
    "  try:\n",
    "    tf.config.experimental.set_virtual_device_configuration(\n",
    "        gpus[0],\n",
    "        [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=2000)])\n",
    "    logical_gpus = tf.config.experimental.list_logical_devices('GPU')\n",
    "    print(len(gpus), \"Physical GPUs,\", len(logical_gpus), \"Logical GPUs\")\n",
    "  except RuntimeError as e:\n",
    "    # Virtual devices must be set before GPUs have been initialized\n",
    "    print(e)\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "load_path_one='./checkpoints/'+input_parameters.dataset_name+'/level_one/'\n",
    "\n",
    "'''\n",
    "load_path_two='./checkpoints/'+input_parameters.dataset_name+'/level_two/'\n",
    "\n",
    "load_path_three='./checkpoints/'+input_parameters.dataset_name+'/level_three/'\n",
    "\n",
    "load_path_four='./checkpoints/'+input_parameters.dataset_name+'/level_four/'\n",
    "'''\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "level_one_network=Level_one()\n",
    "level_one_network.load_weights(load_path_one + 'epoch_'+str(input_parameters.epoch_load_one)+\"_full\")\n",
    "'''\n",
    "level_two_network=Level_two()\n",
    "level_two_network.load_weights(load_path_two + 'epoch_'+str(input_parameters.epoch_load_two)+\"_full\")\n",
    "\n",
    "level_three_network=Level_three()\n",
    "#level_three_network.load_weights(load_path_three + 'epoch_'+str(input_parameters.epoch_load_three)+\"_full\")\n",
    "\n",
    "level_four_network=Level_four()\n",
    "level_four_network.load_weights(load_path_four + 'epoch_'+str(input_parameters.epoch_load_four)+\"_full\")\n",
    "'''\n",
    "\n",
    "\n",
    "def initial_motion():\n",
    "    # prepare source and target four points\n",
    "    matrix_list=[]\n",
    "    for i in range(input_parameters.batch_size):\n",
    "       \n",
    "        src_points=[[0,0],[127,0],[127,127],[0,127]]\n",
    "\n",
    "        tgt_points=[[32,32],[160,32],[160,160],[32,160]]\n",
    "\n",
    "    \n",
    "        src_points=np.reshape(src_points,[4,1,2])\n",
    "        tgt_points=np.reshape(tgt_points,[4,1,2])\n",
    "\n",
    "        # find homography\n",
    "        h_matrix, status = cv2.findHomography(src_points, tgt_points,0)\n",
    "        matrix_list.append(h_matrix)\n",
    "    return np.asarray(matrix_list).astype(np.float32)\n",
    "\n",
    "def construct_matrix(initial_matrix,scale_factor,batch_size):\n",
    "    #scale_factor size_now/(size to get matrix)\n",
    "    initial_matrix=tf.cast(initial_matrix,dtype=tf.float32)\n",
    "    \n",
    "    scale_matrix=np.eye(3)*scale_factor\n",
    "    scale_matrix[2,2]=1.0\n",
    "    scale_matrix=tf.cast(scale_matrix,dtype=tf.float32)\n",
    "    scale_matrix_inverse=tf.linalg.inv(scale_matrix)\n",
    "\n",
    "    scale_matrix=tf.expand_dims(scale_matrix,axis=0)\n",
    "    scale_matrix=tf.tile(scale_matrix,[batch_size,1,1])\n",
    "\n",
    "    scale_matrix_inverse=tf.expand_dims(scale_matrix_inverse,axis=0)\n",
    "    scale_matrix_inverse=tf.tile(scale_matrix_inverse,[batch_size,1,1])\n",
    "\n",
    "    final_matrix=tf.matmul(tf.matmul(scale_matrix,initial_matrix),scale_matrix_inverse)\n",
    "    return final_matrix\n",
    "\n",
    "\n",
    "\n",
    "def average_cornner_error(batch_size,predicted_matrix,u_list,v_list,top_left_u=0,top_left_v=0,bottom_right_u=127,bottom_right_v=127):\n",
    "    \n",
    "    four_conner=[[top_left_u,top_left_v,1],[bottom_right_u,top_left_v,1],[bottom_right_u,bottom_right_v,1],[top_left_u,bottom_right_v,1]]\n",
    "    four_conner=np.asarray(four_conner)\n",
    "    four_conner=np.transpose(four_conner)\n",
    "    four_conner=np.expand_dims(four_conner,axis=0)\n",
    "    four_conner=np.tile(four_conner,[batch_size,1,1]).astype(np.float32)\n",
    "    \n",
    "    new_four_points=tf.matmul(predicted_matrix,four_conner)\n",
    "    \n",
    "    new_four_points_scale=new_four_points[:,2:,:]\n",
    "    new_four_points= new_four_points/new_four_points_scale\n",
    "    \n",
    "    \n",
    "    u_predict=new_four_points[:,0,:]\n",
    "    v_predict=new_four_points[:,1,:]\n",
    "    \n",
    "    average_conner=tf.sqrt(tf.math.pow(u_predict-u_list,2)+tf.math.pow(v_predict-v_list,2))\n",
    "    #print (np.shape(average_conner))\n",
    "    average_conner=tf.reduce_mean(average_conner)\n",
    "    \n",
    "    \n",
    "    return average_conner\n",
    "    \n",
    "\n",
    "\n",
    "def loss_function(batch_size,initial_matrix,predicted_matrix,u_list,v_list,alpha,top_left_u=0,top_left_v=0,bottom_right_u=127,bottom_right_v=127):\n",
    "    d_cornner=average_cornner_error(batch_size,predicted_matrix,u_list,v_list,top_left_u,top_left_v,bottom_right_u,bottom_right_v)\n",
    "    \n",
    "    d_cornner_initial=average_cornner_error(batch_size,initial_matrix,u_list,v_list,top_left_u,top_left_v,bottom_right_u,bottom_right_v)\n",
    "\n",
    "    delta=d_cornner_initial-tf.math.pow(tf.math.maximum(0,tf.math.sqrt(d_cornner_initial)-2*alpha),2)\n",
    "\n",
    "    #print (delta)\n",
    "    total_loss=tf.math.maximum(0,1+delta+d_cornner-d_cornner_initial)\n",
    "    #print (d_cornner)\n",
    "    #print (d_cornner_initial)\n",
    "\n",
    "    #print (total_loss)\n",
    "    return total_loss\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "LK_layer_one=Lucas_Kanade_layer(batch_size=1,height_template=16,width_template=16,num_channels=4)\n",
    "\n",
    "\n",
    "LK_layer_two=Lucas_Kanade_layer(batch_size=1,height_template=32,width_template=32,num_channels=4)\n",
    "\n",
    "\n",
    "LK_layer_three=Lucas_Kanade_layer(batch_size=1,height_template=64,width_template=64,num_channels=4)\n",
    "\n",
    "\n",
    "LK_layer_four=Lucas_Kanade_layer(batch_size=1,height_template=128,width_template=128,num_channels=4)\n",
    "\n",
    "\n",
    "initial_matrix=initial_motion()\n",
    "initial_matrix_scaled=construct_matrix(initial_matrix,scale_factor=0.125,batch_size=input_parameters.batch_size)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "888\n"
     ]
    }
   ],
   "source": [
    "data_loader=data_loader_GoogleMap('val')\n",
    "fk_loop=25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "87.6162338256836\n"
     ]
    }
   ],
   "source": [
    "#file = open(\"./CLKN_GoogleMap.txt\",\"w\") \n",
    "\n",
    "count_sub=0\n",
    "for i in range(6000):\n",
    "    input_img,u_list,v_list,template_img=data_loader.data_read_batch(batch_size=input_parameters.batch_size)\n",
    "    \n",
    "    input_img=input_img\n",
    "    template_img=template_img\n",
    "    \n",
    "    input_feature_one=level_one_network.call(input_img,training=False)\n",
    "        \n",
    "    template_feature_one=level_one_network.call(template_img,training=False)\n",
    "\n",
    "    updated_matrix_one=LK_layer_one.update_matrix(template_feature_one,input_feature_one,initial_matrix_scaled)\n",
    "\n",
    "\n",
    "    '''\n",
    " \n",
    "    for j in range(fk_loop):\n",
    "        try:\n",
    "            updated_matrix_one=LK_layer_one.update_matrix(template_feature_one,input_feature_one,updated_matrix_one)\n",
    "        except:\n",
    "            break\n",
    "         \n",
    "    updated_matrix_one=construct_matrix(updated_matrix_one,scale_factor=2,batch_size=input_parameters.batch_size)\n",
    "\n",
    "    input_feature_two=level_two_network.call(input_img,training=False)\n",
    "        \n",
    "    template_feature_two=level_two_network.call(template_img,training=False)\n",
    "\n",
    "    updated_matrix_two=LK_layer_two.update_matrix(template_feature_two,input_feature_two,updated_matrix_one)\n",
    "\n",
    "    for j in range(fk_loop):\n",
    "        try:\n",
    "            updated_matrix_two=LK_layer_two.update_matrix(template_feature_two,input_feature_two,updated_matrix_two)\n",
    "        except:\n",
    "            break\n",
    "  \n",
    "    updated_matrix_two=construct_matrix(updated_matrix_two,scale_factor=2,batch_size=input_parameters.batch_size)\n",
    "\n",
    "    input_feature_three=level_three_network.call(input_img,training=False)\n",
    "        \n",
    "    template_feature_three=level_three_network.call(template_img,training=False)\n",
    "\n",
    "    updated_matrix_three=LK_layer_three.update_matrix(template_feature_three,input_feature_three,updated_matrix_two)\n",
    "\n",
    "    \n",
    "    for j in range(fk_loop):\n",
    "        try:\n",
    "            updated_matrix_three=LK_layer_three.update_matrix(template_feature_three,input_feature_three,updated_matrix_three)\n",
    "        except:\n",
    "            break\n",
    "    \n",
    "    updated_matrix_three=construct_matrix(updated_matrix_three,scale_factor=2,batch_size=input_parameters.batch_size)\n",
    "    \n",
    "    \n",
    "\n",
    "    input_feature_four=level_four_network.call(input_img,training=False)\n",
    "        \n",
    "    template_feature_four=level_four_network.call(template_img,training=False)\n",
    "\n",
    "    feature=LK_layer_four.projective_inverse_warp(input_feature_four,updated_matrix_three)\n",
    "    updated_matrix_four=LK_layer_four.update_matrix(template_feature_four,input_feature_four,updated_matrix_three)\n",
    "\n",
    "    \n",
    "  \n",
    "    for j in range(fk_loop):\n",
    "        try:\n",
    "            updated_matrix_four=LK_layer_four.update_matrix(template_feature_four,input_feature_four,updated_matrix_four)\n",
    "        except:\n",
    "            break\n",
    "    \n",
    "    '''\n",
    "    predicted_matrix=updated_matrix_one\n",
    "    \n",
    "    \n",
    "    \n",
    "\n",
    "    \n",
    "   \n",
    "    cornner_error=average_cornner_error(1,predicted_matrix,u_list,v_list,top_left_u=0,top_left_v=0,bottom_right_u=127,bottom_right_v=127)\n",
    "    each_error=cornner_error\n",
    "    print (i)\n",
    "    print (np.float(each_error))\n",
    "    if each_error<1.0:\n",
    "        count_sub=count_sub+1\n",
    "        print (count_sub/(i+1))\n",
    "    break\n",
    "    #file.write(str(np.float(each_error)))\n",
    "    #file.write('\\n')\n",
    "\n",
    "#file.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP8AAAD4CAYAAAAjDTByAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAOgklEQVR4nO3dfYxl9V3H8fdXFkToCou7Up7ShQZJs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wFuBnwP2An/SxTcdMvx7gLPGvj6zuW/RZSJiBXAS8J9dFxIRxzIK/u2ZedfCxzPz1cz87+b2vcCxEbG66zqa77+n+bwPuJvR4du4acatC5cDOzLzxUVqHGw8Gi8efGnTfN63yDKDjEtEXANcCfx684foDaZ4DlvJzBcz838z8wfAX0/4/ksejyHD/23g3Ig4u9nLbATuWbDMPcDBs7bvBb4+acBLNecQbgF2ZeanJyzz5oPnGiLiYkbj1McfoRMjYuXB24xOMD26YLF7gN9szvpfArwydkjcpauYcMg/1HiMGf89uBr48iLLfBW4LCJWNYfBlzX3dSYi1gM3Au/OzO9PWGaa57BtHePneH5twvefJl/zdXGGcglnMq9gdHb9KeCm5r4/YjS4AMczOuzcDfwLcE4PNbyT0WHkw8DO5uMK4EPAh5plrgMeY3TG9EHgHT2NxznNNh5qtndwTMZrCeAzzZg9Asz1UMeJjMJ80th9g4wHoz84e4HXGb1O/QCj8zwPAE8CXwNOaZadA24eW/fa5ndlN/D+HurYzeh19MHfk4P/iToduPdQz2HHdfxd89w/zCjQpy2sY1K+DvXh5b1Spao94SfVzvBLlTL8UqUMv1Qpwy9VyvBLlTL8UqX+D6fUBmVa02RyAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.imshow(template_feature_one[0,:,:,:3]*100)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZX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TVANkRtiBJAg7kARhB5Ig7EAShB1IgrADSRB2IIlOp386qtVyy/DyJX0FtabkAbpT8Kotes1O/sLmzA4kQdiBJAg7kARhB5Ig7EAShB1IgrADSRB2IIlup3+yz2tuXrhLVku60FkB9SzHuqm5O33W/cuIWHBu9E7D/pOd2+O5eduXl+VYNzV3Z6h18zYeSIKwA0n0HfY9Pe9/UsuxbmruziDr7vUzO4Du9H1mB9ARwg4k0VvYbW+3/bntE7Z391XHlbB90vbHto/Zbp3cpi+299o+Z/v4vGU32j5k+4vm8oY+a7zcIjU/bft0c7yP2b6nzxovZ3uD7fdsf2r7E9uPNcsHeax7CbvtVZJekHS3pM2SHrS9uY9aJnBnRGwZ4u+o8+yTtP2yZbslHY6ITZION7eHZJ9+WrMkPd8c7y0RcbDjmtpclPRERGyWdJukR5rX8SCPdV9n9m2STkTElxHxvaTXJe3oqZYVJyKOSPrmssU7JO1vru+XWsYH69giNQ9aRJyJiA+b699J+kzSeg30WPcV9vWSvpp3+1SzbOhC0ru2j9re1XcxV2htRJxprn8taW2fxVyBR21/1LzNH8Tb4YXY3ijpVknva6DHmi/orsztEfFbzX38eMT27/suaBIx93vrcvjN9UVJt0jaIumMpGf7LWdhtq+T9KakxyPi2/n3DelY9xX205I2zLt9U7Ns0CLidHN5TtLbmvs4slyctb1OkprLcz3X0yoizkbEDxHxo6SXNMDjbftqzQX9lYh4q1k8yGPdV9g/kLTJ9s22r5H0gKQDPdVSxPa1tq+/dF3SXZKOL/1Xg3JA0s7m+k5J7/RYS5FLgWncp4Edb9uW9LKkzyLiuXl3DfJY99ZB1/yM8jdJqyTtjYi/9lJIIdu/0tzZXJobb//VodZs+zVJd2juv1qelfSUpL9LekPSLzT334zvj4jBfCG2SM13aO4tfEg6KenheZ+Fe2f7dkn/kvSxpB+bxU9q7nP74I417bJAEnxBByRB2IEkCDuQBGEHkiDsQBKEHUiCsANJ/A/scuJi2Ps67wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.imshow(input_feature_one[0,:,:,:3]*100)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
